package com.earthchen.domain.entity.user;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.earthchen.domain.entity.BaseEntity;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.List;


/**
 * 资源对象 sys_resource
 *
 * @author 占超群
 */
@TableName("t_sys_resource")
public class Resource extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /**
     * 资源名称
     */
    @NotEmpty(message = "资源名称不能为空")
    private String resourceName;

    /**
     * 父资源名称
     */
    @TableField(exist = false)
    private String parentName;

    /**
     * 父资源ID
     */
    @JsonProperty("pid")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentId;

    /**
     * 显示顺序
     */
    private String orderNum;

    /**
     * 资源URL
     */
    @NotEmpty(message = "资源url不能为空")
    private String url;

    /**
     * 类型:0目录,1菜单,2按钮
     */
    @NotEmpty(message = "资源类型不能为空")
    private String resourceType;

    /**
     * 资源状态:0显示,1隐藏
     */
    private String visible;

    /**
     * 权限字符串
     */
    private String perms;

    /**
     * 资源图标
     */
    private String icon;
    /**
     * 创建者
     */
    private String createBy;

    /**
     * 更新者
     */
    private String updateBy;

    /**
     * 标记备注
     */
    private String remark;
    /**
     * 子资源
     */
    @TableField(exist = false)
    private List<Resource> children = new ArrayList<Resource>();

    public String getParentName()
    {
        return parentName;
    }

    public static long getSerialVersionUID()
    {
        return serialVersionUID;
    }


    public String getResourceName()
    {
        return resourceName;
    }

    public void setResourceName(String resourceName)
    {
        this.resourceName = resourceName;
    }

    public String getRemark()
    {
        return remark;
    }

    public void setRemark(String remark)
    {
        this.remark = remark;
    }

    public String getResourceType()
    {
        return resourceType;
    }

    public void setResourceType(String resourceType)
    {
        this.resourceType = resourceType;
    }

    public void setParentName(String parentName)
    {
        this.parentName = parentName;
    }

    public Long getParentId()
    {
        return parentId;
    }

    public void setParentId(Long parentId)
    {
        this.parentId = parentId;
    }

    public String getOrderNum()
    {
        return orderNum;
    }

    public void setOrderNum(String orderNum)
    {
        this.orderNum = orderNum;
    }

    public String getUrl()
    {
        return url;
    }

    public void setUrl(String url)
    {
        this.url = url;
    }

    public String getVisible()
    {
        return visible;
    }

    public void setVisible(String visible)
    {
        this.visible = visible;
    }

    public String getPerms()
    {
        return perms;
    }

    public void setPerms(String perms)
    {
        this.perms = perms;
    }

    public String getIcon()
    {
        return icon;
    }

    public void setIcon(String icon)
    {
        this.icon = icon;
    }

    public List<Resource> getChildren()
    {
        return children;
    }

    public void setChildren(List<Resource> children)
    {
        this.children = children;
    }

    public String getCreateBy()
    {
        return createBy;
    }

    public void setCreateBy(String createBy)
    {
        this.createBy = createBy;
    }

    public String getUpdateBy()
    {
        return updateBy;
    }

    public void setUpdateBy(String updateBy)
    {
        this.updateBy = updateBy;
    }

    @Override
    public String toString()
    {
        return "Resource{" +
               "resourceName='" + resourceName + '\'' +
               ", parentName='" + parentName + '\'' +
               ", parentId=" + parentId +
               ", orderNum='" + orderNum + '\'' +
               ", url='" + url + '\'' +
               ", resourceType='" + resourceType + '\'' +
               ", visible='" + visible + '\'' +
               ", perms='" + perms + '\'' +
               ", icon='" + icon + '\'' +
               ", createBy='" + createBy + '\'' +
               ", updateBy='" + updateBy + '\'' +
               ", remark='" + remark + '\'' +
               ", children=" + children +
               '}';
    }
}
